![]() |
VisibleLength |
||||
Header: | QuickdrawText.h | Carbon status: | Supported | |
Calculates the length, in bytes, of a given text segment, excluding trailing white space.
SInt32 VisibleLength ( Ptr textPtr, SInt32 textLength );
A pointer to a text string.
The number of bytes in the text segment.
The length, in bytes, of a given text segment, excluding trailing white space.
The VisibleLength function determines how much of a style run to display, without displaying trailing spaces. You call VisibleLength for the last style run of a line in memory order. The last style run in memory order of the text constituting the line is not always the last style run in display order. For a line of unidirectional left-to-right text, the last style run in memory order is the rightmost style run in display order. For a line of unidirectional right-to-left text, the last style run in memory order is the leftmost style run in display order. However, if the text contains mixed directions, the last style run in memory order may be an interior style run in display order.
The text justification functions do not automatically exclude trailing spaces, so you pass them the value that VisibleLength returns as the length of the last style run in memory order.
The VisibleLength function behaves differently for various script systems. For simple script systems, such as Roman and Cryllic, and for 2-byte script systems, VisibleLength does not include in the byte count it returns trailing spaces that occur at the display end of the text segment. For 2-byte script systems, VisibleLength does not count them, whether they are 1-byte or 2-byte space characters.
For 1-byte complex script systems, VisibleLength does not include in the byte count that it returns spaces whose character direction is the same as the primary line direction. For 1-byte complex script systems that support bidirectional text, Roman spaces take on a character direction based on the primary line direction. If the Roman spaces then fall at the end of the text, VisibleLength does not include them in the returned byte count.
The purpose of VisibleLength is to trim off white space at the display end of the line. The VisibleLength function does not eliminate the white space by removing its character code from memory. Rather, it does not include white space characters in the count that it returns as the length of the range of text for which you call it.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)